<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<script type="text/javascript" >
function enableflightNumberField(isToEnable) {	
	dojo.byId("departingCity").disabled = isToEnable;
	dojo.byId("destinationCity").disabled = isToEnable;
	dojo.byId("flightNumber").disabled = !isToEnable;
}
</script>

<form:form modelAttribute="flight" action="searchFlightStatus">
	
	

	<div class="section"><span class="errors"> <form:errors path="*" /> </span>
	<br/>
	
	<h2>Search Flight Status</h2>

	<fieldset>
	
	<div class="field">
	<div class="label">Flight Number: </div>
	<div class="input"><form:input path="flightNumber" maxlength="15" />	</div>	
	</div>
	

	<div class="field">
	<div class="label">Departing City:</div>
	<div class="input"><form:select path="departingCity" itemLabel="name" itemValue="id" items="${cityList}" /></div>
	</div>

	<div class="field">
	<div class="label">Destination City:</div>
	<div class="input"><form:select path="destinationCity" itemLabel="name" itemValue="id" items="${cityList}" /></div>
	</div>


	<div class="field">
	<div class="label">Departure Date: </div>
	<div class="input"><form:input path="departureDate" /> </div> 
	<script type="text/javascript">
	Spring.addDecoration(new Spring.ElementDecoration( {
		elementId : "departureDate",
		widgetType : "dijit.form.DateTextBox",
		widgetAttrs : { required: true, datePattern : "MM-dd-yyyy"}  	}));
	</script>	
	</div>

	<div class="field">
	<div class="label">Search By:</div>
	<div class="input">
	
	
	<form:radiobutton path="searchBy" value="flightNumber" onclick="enableflightNumberField(true);" />Flight Number
	<form:radiobutton path="searchBy" value="city" onclick="enableflightNumberField(false);" />City	
	<!-- 
	<input type="radio" name="searchBy" value="flightNumber" checked="checked" onclick="enableflightNumberField(true);"/> Flight Number 
	<input type="radio" name="searchBy" value="city" onclick="enableflightNumberField(false);" />City
	 -->	
	</div>
	</div>



	<div class="buttonGroup"><input type="submit" id="btnFindFlights" value="Find Flights" />	
	</div>
	
	</fieldset>
	
	
	<script type="text/javascript">
	enableflightNumberField(${'flightNumber' == flight.searchBy});
	</script>


	</div>
</form:form>

<%@include file="flightList.jsp"%>
